package com.hnichr.ump.common.assessment.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.persistence.Column;
import java.io.Serializable;

@Data
@Schema(description = "受测者注册结果")
public class TesteeRegisterResultVO implements Serializable {
    private static final long serialVersionUID = 1L;


    @Schema(description = "注册结果 00-注册成功，跳转自己的考试页面 01-注册成功，直接跳转北森页面  99-注册失败")
    private String result;

    @Schema(description = "受测邀请ID")
    private String inviteId ;

    @Schema(description = "测评链接")
    private String url;

    @Schema(description = "错误信息")
    private String msg;

    @Schema(description = "本地试卷")
    private PaperVO paper;

    enum RESULT{
        REDIRECT_LOCAL_PAPER("00"), REDIRECT_BEISEN_URL("01"), ERROR("99");
        private String code;

        RESULT(String code){
            this.code = code;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }
    }

    public static TesteeRegisterResultVO error(String msg){
        TesteeRegisterResultVO vo = new TesteeRegisterResultVO();
        vo.setResult(RESULT.ERROR.getCode());
        vo.setMsg(msg);
        return vo;
    }

    public static TesteeRegisterResultVO redirectBeisenUrl(String url){
        TesteeRegisterResultVO vo = new TesteeRegisterResultVO();
        vo.setResult(RESULT.REDIRECT_BEISEN_URL.getCode());
        vo.setUrl(url);
        return vo;
    }

    public static TesteeRegisterResultVO redirectLocalPaper(PaperVO paper,String inviteId,String url){
        TesteeRegisterResultVO vo = new TesteeRegisterResultVO();
        vo.setResult(RESULT.REDIRECT_LOCAL_PAPER.getCode());
        vo.setPaper(paper);
        vo.setInviteId(inviteId);
        vo.setUrl(url);
        return vo;
    }

}
